package com.wego.controller;

import com.wego.bean.TableBean;
import com.wego.common.bean.PageBean;
import com.wego.entity.domain.Admin;
import com.wego.entity.query.AdminQuery;
import com.wego.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
 *
 */
//
/**
 * 管理员控制器
 * @author Li Chuanwei
 */
@RestController
@RequestMapping("/manager/admin")
public class AdminController {

    @Autowired
    private AdminService adminService;

    @GetMapping("/list")
    @ResponseBody
    public TableBean list(AdminQuery adminQuery) {
        //构造动态查询条件
        PageBean<Admin> adminPageBean = adminService.selectPage(adminQuery);
        List<Admin> admin = adminPageBean.getResult();
        Long count = adminPageBean.getTotal();
        TableBean tableBean = new TableBean<Admin>();
        tableBean.setCode(0);
        tableBean.setMsg("");
        tableBean.setData(admin);
        tableBean.setCount(count);
        return tableBean;
    }


}
